package com.bst.web.base;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bst.common.annotation.Log;
import com.bst.common.enums.BusinessType;
import com.bst.md.domain.MdIndexSuffix;
import com.bst.md.service.IMdIndexSuffixService;
import com.bst.common.core.controller.BaseController;
import com.bst.common.core.domain.AjaxResult;
import com.bst.common.utils.poi.ExcelUtil;
import com.bst.common.core.page.TableDataInfo;

/**
 * 指标后缀Controller
 * 
 * @author ruoyi
 * @date 2023-08-19
 */
@Controller
@RequestMapping("/md/index/suffix")
public class MdIndexSuffixController extends BaseController
{
    private String prefix = "system/md/index/suffix";

    @Autowired
    private IMdIndexSuffixService mdIndexSuffixService;

    @GetMapping()
    public String suffix()
    {
        return prefix + "/suffix";
    }

    /**
     * 查询指标后缀列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MdIndexSuffix mdIndexSuffix)
    {
        startPage();
        List<MdIndexSuffix> list = mdIndexSuffixService.selectMdIndexSuffixList(mdIndexSuffix);
        return getDataTable(list);
    }

    /**
     * 导出指标后缀列表
     */
    @Log(title = "指标后缀", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MdIndexSuffix mdIndexSuffix)
    {
        List<MdIndexSuffix> list = mdIndexSuffixService.selectMdIndexSuffixList(mdIndexSuffix);
        ExcelUtil<MdIndexSuffix> util = new ExcelUtil<MdIndexSuffix>(MdIndexSuffix.class);
        return util.exportExcel(list, "指标后缀数据");
    }

    /**
     * 新增指标后缀
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存指标后缀
     */
    @Log(title = "指标后缀", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MdIndexSuffix mdIndexSuffix)
    {
        return toAjax(mdIndexSuffixService.insertMdIndexSuffix(mdIndexSuffix));
    }

    /**
     * 修改指标后缀
     */
    @GetMapping("/edit/{idSuffix}")
    public String edit(@PathVariable("idSuffix") Long idSuffix, ModelMap mmap)
    {
        MdIndexSuffix mdIndexSuffix = mdIndexSuffixService.selectMdIndexSuffixByIdSuffix(idSuffix);
        mmap.put("mdIndexSuffix", mdIndexSuffix);
        return prefix + "/edit";
    }

    /**
     * 修改保存指标后缀
     */
    @Log(title = "指标后缀", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MdIndexSuffix mdIndexSuffix)
    {
        return toAjax(mdIndexSuffixService.updateMdIndexSuffix(mdIndexSuffix));
    }

    /**
     * 删除指标后缀
     */
    @Log(title = "指标后缀", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(mdIndexSuffixService.deleteMdIndexSuffixByIdSuffixs(ids));
    }
}
